package com.aiss.ws.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.aiss.ws.Entity.CurseItem;
import com.aiss.ws.R;

import java.util.List;

/**
 * Created by chenqiang on 15/12/29.
 */
public class AgreenonAdatper extends BaseAdapter {

    private List<CurseItem> datas;
    private Context context;
    private String time;

    public AgreenonAdatper(List<CurseItem> datas, Context context, String time) {
        this.time = time;
        this.datas = datas;
        this.context = context;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if(convertView==null){
            holder = new Holder();
            convertView = LayoutInflater.from(context).inflate(R.layout.agreenon_item,null);
            holder.name_tv1 = (TextView) convertView.findViewById(R.id.name_tv1);
            holder.name_tv2 = (TextView) convertView.findViewById(R.id.name_tv2);
            holder.name_tv3 = (TextView) convertView.findViewById(R.id.name_tv3);
            holder.name_tv4 = (TextView) convertView.findViewById(R.id.name_tv4);
            holder.name_tv5 = (TextView) convertView.findViewById(R.id.name_tv5);
            convertView.setTag(holder);
        }else{
            holder = (Holder) convertView.getTag();
        }

        int time1 = Integer.parseInt(time.substring(0,4))+1;
        String time2 = time1 + time.substring(4,time.length());

        holder.name_tv1.setText("课程名称:\t《"+datas.get(position).getNamex()+"》");
        holder.name_tv2.setText("服务类型:\t"+"爱考网该科目当前考试复习资料");
        holder.name_tv3.setText("服务费用:\t"+datas.get(position).getPrice());
        holder.name_tv4.setText("服务时间:\t"+time+"~"+time2);
        holder.name_tv5.setText("服务内容:\t"+datas.get(position).getNamex()+"68小时学习时间");


        return convertView;
    }

    class Holder{
        TextView name_tv1;
        TextView name_tv2;
        TextView name_tv3;
        TextView name_tv4;
        TextView name_tv5;
    }

}
